<<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>html;charset=utf-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
		<meta http-equiv="expires" content="Wed, 26 Feb 1970 08:21:57 GMT" />
		<link href="<c:url value='/images/css/style.css' />" rel="stylesheet" type="text/css" />
		<title>ycnShop 购物车</title>
        <script language="javascript">
			function updateMc(nid,count) {
				var newCountid = "newCount_" + nid.toString();
				var newCount=document.getElementById(newCountid).value;
				if(newCount != count) {
					if(newCount>0) {
						if(confirm('您确定要修改购买商品的数量吗？')) {
							location.href="<c:url value='/servlet/CartServlet?fromPage=/Cart.jsp'/>&nid=" + nid + "&newCount="+ newCount +"&act=updateMc";
						}
					} else {
						alert("商品数量不能小于1,如果不想购买请点击删除按钮 ");
						document.getElementById('mcCount').value=count;
					}
				} else {
					alert("您并没有修改商品数量！");
				}
			}
			
			function deleteMc(nid) {
				if(confirm('您确实要把该商品移出购物车吗？')) {
					location.href="<c:url value='/servlet/CartServlet?fromPage=/Cart.jsp'/>&nid=" + nid + "&act=deleteMc";
				}
			}
			
			function clearMc(nid) {
				if(${mcCart.mcCount!=0}) {
					if(confirm('您确定要清空购物车吗？')) {
						location.href="<c:url value='/servlet/CartServlet?fromPage=/Cart.jsp'/>&act=clearMc";
					}
				} else {
					alert("购物车内并没有商品，清空失败");
				}
			}
			
			function addOrder() {
				if(${mcCart.mcCount!=0}) {
					location.href="<c:url value='/Paymode.jsp'/>";
				} else {
					alert("购物车内并没有商品，不能结账");
				}
			}
			
			function onKeyUpdateMc(nid,count){
				if(event.keyCode==13){
					updateMc(nid,count);
				}
			}
		</script>
	</head>
	<body>
		<div id="container">
			<div id="globalHeader">
				<p id="logo">
					<a href="<c:url value='/Show.jsp' />"><img src="<c:url value='/images/logo.gif' />" alt="logo" />
					</a>
				</p>
  <ul id="globalTopNav">
      <li><a href="<c:url value='/User_Reg.jsp' />" >用户注册</a></li>
      <li><a href="<c:url value='/User_Login.jsp' />" >用户登陆</a></li>
      <li><a href="<c:url value='/User/Change_Info.jsp' />" >会员中心</a></li>
      <li><a href="<c:url value='/Cart.jsp' />" >购物车</a></li>
      <li><a href="<c:url value='/User/Show_Orderlist.jsp' />" >查看订单</a></li>
      <li id="globalTopNavLast"><a href="<c:url value='/Admin_Login.jsp' />" >后台管理</a></li>
      <li id="globalTopNavRight">&nbsp;</li>
  </ul>
			</div>
			<div id="globalNav">
				<ul>
					<li id="currentPage">
						<a href="<c:url value='/Show.jsp' />">首页</a>
					</li>
					<li>
						<a href="<c:url value='/User/Change_Info.jsp' />">会员中心</a>
					</li>
					<li>
						<a href="<c:url value='/User/Show_Orderlist.jsp' />">查看订单</a>
					</li>
				</ul>
			</div>
            <div id="ECS_MEMBERZONE">
				<c:choose>
					<c:when test="${sessionScope.user ne null}">
						<span class="welcome">您好，${sessionScope.user.suser}，欢迎回来!</span>
						<span class="btnList"><a
							href="<c:url value="/User/Change_Info.jsp" />">进入用户中心</a><a
							href="<c:url value="/servlet/LogoutServlet?act=user" />">退出</a> </span>
					</c:when>
					<c:when test="${sessionScope.user==null}">
						<form id="ECS_LOGINFORM" name="loginUser" method="post"
							action="<c:url value="/servlet/LoginServlet" />"
							onsubmit="return checkLoginForm();">
							用户名：
							<input name="suser" type="text" size="8" tabindex="1"
								value="${cookie.suser.value}" class="textInput textInputSign" />
							密码：
							<input name="spwd" type="password" size="10" tabindex="2"
								class="textInput textInputSign" />
							验证码：
							<input name="rand" type="text" class="textInput textCaptcha"
								size="4" maxlength="4" />
							&nbsp;
							<img src="<c:url value="/inc/rand.jsp" />"
								onclick="this.src='<c:url value="/inc/rand.jsp" />'"
								class="imgrand" />
							<input type="image"
								src="<c:url value="/images/btn_signin.gif" />" />
							<input type="hidden" name="fromPage"
								value="<c:url value="/index.jsp" />" />
							<input type="hidden" name="msg"
								value="<c:url value="/msg.jsp" />" />
							<span onclick="javascript:location.href='<c:url value='/User_Reg.jsp' />'" style=" cursor:hand;">
                            <img src="<c:url value="/images/btn_register.gif" />" alt="" /></span>
						</form>
					</c:when>
				</c:choose>
			</div>
    <div id="urHere" class="globalModule globalFrame">
      <h3>当前位置: <a href="<c:url value='/Show.jsp' />">首页</a> <code>&gt;</code> 购物车</h3>
    </div>
        <div id="globalCart" class="globalModule globalFrame">
      <h3>商品列表</h3>
      <div class="globalModuleContent">
          <table border="0" cellspacing="0" class="cartlist">
          	<tr>
              <th colspan="7">
              <span style="float:left;"><img src="<c:url value='/images/cartnavi-1.gif' />" alt="购物流程图" /></span>
              </th>
            </tr>
            <tr>
              <th width="50">编号</th>
              <th width="100">图片</th>
              <th width="250">名称</th>
              <th width="150">单价</th>
              <th width="100">数量</th>
              <th width="100">小计</th>
              <th width="150">操作</th>
            </tr>
<c:forEach var="mcMap" items="${mcCart.mcMap}" >
	<c:set var="mc" value="${mcMap.value}" />
            <tr>
              <td width="50">&nbsp;${mc.mcBean.nid}&nbsp;</td>
              <td width="100">&nbsp;<a href="<c:url value='/servlet/McInfoServlet?mcNid=${mc.mcBean.nid}&fromPage=/Mcinfo.jsp' />" title="点击查看商品详细信息"  target="_blank">
              <img src="<c:url value='/mcimg/${mc.mcBean.simg}' />" class="mcimg" /></a>&nbsp;</td>
              <td width="250">&nbsp;
              <a href="<c:url value='/servlet/McInfoServlet?mcNid=${mc.mcBean.nid}&fromPage=/Mcinfo.jsp' />" title="点击查看商品详细信息"  target="_blank">	${mc.mcBean.sname}
              </a>&nbsp;</td>
              <td width="150">&nbsp;￥${mc.mcBean.nprice}&nbsp;</td>
              <td width="100">
              	<input type="text" value="${mc.count}" id="newCount_${mc.mcBean.nid}" class="textInput" onkeydown="onKeyUpdateMc(${mc.mcBean.nid},${mc.count});" />
                <span onclick="updateMc(${mc.mcBean.nid},${mc.count});" style="cursor:hand;">
                <img src="<c:url value='/images/icon_edit.gif' />" alt="点击修改购买商品数！" />
                </span>
              </td>
              <td width="100">￥${mc.mcBean.nprice*mc.count}</td>
              <td width="150">
                 <span onclick="deleteMc(${mc.mcBean.nid});" style="cursor:hand;"><img src="<c:url value='/images/no.gif' />" alt="点击删除此商品" /></span>
              </td>
            </tr>
</c:forEach>
            <tr>
              <td colspan="7" class="textStrong">
                <span style="float:right;">您一共买了&nbsp;${mcCart.mcTypeCount}&nbsp;种商品，一共是&nbsp;${mcCart.mcCount}&nbsp;件，购物金额总计&nbsp;￥${mcCart.totalPrice}&nbsp;元。</span>
              </td>
              <td>&nbsp;</td>
              <td>
              </td>
            </tr>
            <tr>
              <td colspan="7">
              <span style="float:left;">
                <a href="Show.jsp"><img src="<c:url value='/images/cart_c.gif' />" alt="点击返回首页继续购物" /></a>
                <span onclick="clearMc();" style="cursor:hand;"><img src="<c:url value='/images/cart_q.gif' />" alt="清空商品" /></span>
                <span onclick="addOrder();" style="cursor:hand;"><img src="<c:url value='/images/cartbuy.png' />" align="结账下订单" /></span>
                </span>
              </td>
            </tr>
          </table>
      </div>
    </div>
			<div id="globalFooter">
				<div id="footerLine">
					<img src="<c:url value='/images/footer_line.gif' />" alt="" />
				</div>
				<p id="footerNav">
					<a href="#">免责条款</a> |
					<a href="#">隐私保护</a> |
					<a href="#">咨询热点</a> |
					<a href="#">联系我们</a> |
					<a href="#">公司简介</a> |
					<a href="#">预留功能</a> |
					<a href="<c:url value='/Admin_Login.jsp' />">后台管理</a>
				</p>
			</div>
		</div>
	</body>
</html>
